package top.pcat.entity;

import lombok.Data;
import top.pcat.util.NanoIdUtils;

import java.util.Date;

@Data
public class Message {

    private String senderId;

    private String senderName;

    private String serverId;

    private long roomId;

    private String roomName;

    private String mesType;

    private String mesContent;


    /**
     * 1介绍和选择聊天室
     * 2发红包
     * 3抢红包
     * 5随机私聊
     */
    private int controller;

    private Date date = new Date();

    public Message() {}

    public Message(String senderId, String senderName, long roomId, String roomName, String mesType, String mesContent, int controller, Date date) {
        this.senderId = senderId;
        this.senderName = senderName;
        this.roomId = roomId;
        this.roomName = roomName;
        this.mesType = mesType;
        this.mesContent = mesContent;
        this.controller = controller;
        this.date = date;
    }

    /**
     * kafka
     * @param senderId
     * @param roomId
     * @param mesContent
     */
    public Message(String senderId, long roomId, String mesContent,String senderName) {
        this.senderId = senderId;
        this.roomId = roomId;
        this.mesType = "kf";
        this.mesContent = mesContent;
        this.controller = 2;
        this.senderName = senderName;
    }


    /**
     * 系统消息
     * @param senderId
     * @param senderName
     * @param mesContent
     */
    public Message(String senderId, String senderName, String mesContent) {
        this.senderId = senderId;
        this.senderName = senderName;
        this.mesContent = mesContent;
        this.mesType = "sys";
        this.roomId = 0;
        this.controller = 1;
    }


    public static String newSenderId() {
        return NanoIdUtils.randomNanoId();
    }
}
